
      <p>javascript,es6+</p>
<h1 class="mume-header" id="%E4%B8%80%E5%8F%A5%E8%AF%9D%E6%98%8E%E7%99%BD%E7%AE%AD%E5%A4%B4%E5%87%BD%E6%95%B0%E4%B8%AD%E7%9A%84this">&#x4E00;&#x53E5;&#x8BDD;&#x660E;&#x767D;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E2D;&#x7684;this</h1>

<p>&#x5173;&#x4E8E;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E2D;this&#x503C;&#x7684;&#x95EE;&#x9898;&#xFF0C;&#x7F51;&#x4E0A;&#x67E5;&#x67E5;&#xFF0C;&#x4F1A;&#x544A;&#x8BC9;&#x4F60; &#x201C;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x7684;this&#x56FA;&#x5B9A;&#x5316;&#xFF0C;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E2D;&#x7684;this&#x7ED1;&#x5B9A;&#x5B9A;&#x4E49;&#x65F6;&#x6240;&#x5728;&#x7684;&#x4F5C;&#x7528;&#x57DF;......&#x201D;&#xFF0C;&#x597D;&#x7ED5;&#xFF01;</p>
<blockquote>
<p>&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E2D;this&#x5012;&#x5E95;&#x6307;&#x5411;&#x8C01;&#xFF1F;&#x4E00;&#x53E5;&#x8BDD;&#xFF0C;<strong>&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x5185;&#x7684;this&#x5C31;&#x662F;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x5916;&#x7684;&#x90A3;&#x4E2A;this&#xFF01;</strong> &#x4E3A;&#x4EC0;&#x4E48;&#xFF1F;&#x56E0;&#x4E3A;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x6CA1;&#x6709;&#x81EA;&#x5DF1;&#x7684;this&#x3002;<br>
&#x5982;&#x679C;&#x4F60;&#x5DF2;&#x660E;&#x767D;&#x8FD9;&#x53E5;&#x8BDD;&#x7684;&#x610F;&#x601D;&#xFF0C;&#x90A3;&#x4E48;&#x672C;&#x6587;&#x5230;&#x6B64;&#x7ED3;&#x675F;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x53BB;&#x770B;&#x770B;&#x522B;&#x7684;&#x66F4;&#x6709;&#x8425;&#x517B;&#x7684;&#x4E1C;&#x897F;&#x4E86;&#x3002;<br>
&#x5982;&#x679C;&#x6211;&#x8FD9;&#x53E5;&#x8BDD;&#x63CF;&#x8FF0;&#x7684;&#x4E0D;&#x591F;&#x6E05;&#x695A;&#xFF0C;&#x6216;&#x4F60;&#x5BF9;&#x5B83;&#x6709;&#x6000;&#x7591;&#xFF0C;&#x8BF7;&#x7EE7;&#x7EED;&#x5F80;&#x4E0B;&#x770B;&#x3002;&#x5982;&#x679C;&#x8BF4;&#x9519;&#x4E86;&#x8BF7;&#x4F7F;&#x52B2;&#x62CD;&#x7816;&#x3002;</p>
</blockquote>
<p><strong>&#x76F4;&#x63A5;&#x4E0A;&#x4EE3;&#x7801;&#xFF01;</strong></p>
<blockquote>
<p>&#x6CE8;&#xFF1A;&#x4EE5;&#x4E0B;&#x4EE3;&#x7801;&#x5168;&#x57FA;&#x4E8E;&#x6D4F;&#x89C8;&#x5668;&#x975E;&#x4E25;&#x683C;&#x6A21;&#x5F0F;&#x8FD0;&#x884C;&#xFF0C;&#x4E14;&#x5047;&#x5B9A;&#x4F60;&#x5DF2;&#x7ECF;&#x5BF9;&#x975E;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E2D;&#x7684;this&#x5168;&#x7136;&#x4E86;&#x89E3;</p>
</blockquote>
<p>&#x54B1;&#x5148;&#x5B9A;&#x4E49;&#x4E00;&#x4E2A;&#x5168;&#x5C40;&#x53D8;&#x91CF;a&#xFF0C;&#x540E;&#x9762;&#x6240;&#x6709;&#x7684;&#x793A;&#x4F8B;&#x90FD;&#x5047;&#x5B9A;&#x6B64;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x5DF2;&#x5B58;&#x5728;:</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">var</span> a <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span>
</pre><h4 class="mume-header" id="%E7%AC%AC%E4%B8%80%E4%B8%AA%E7%A4%BA%E4%BE%8B">&#x7B2C;&#x4E00;&#x4E2A;&#x793A;&#x4F8B;&#xFF1A;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// demo1</span>
<span class="token keyword">var</span> obj <span class="token operator">=</span>  <span class="token punctuation">{</span>
  a<span class="token punctuation">:</span> <span class="token number">1</span><span class="token punctuation">,</span>
  b1<span class="token punctuation">:</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">,</span>
  b2<span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj<span class="token punctuation">.</span>b1<span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 0</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj<span class="token punctuation">.</span><span class="token function">b2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 0</span>
</pre><p>&#x6839;&#x636E;&#x7ED3;&#x679C;&#x53EF;&#x4EE5;&#x770B;&#x5230;obj&#x5BF9;&#x8C61;&#x4E2D;&#x7684;&#x5C5E;&#x6027;b1&#x7684;&#x503C;&#x6765;&#x81EA;<strong>&#x5168;&#x5C40;&#x53D8;&#x91CF;a</strong>&#xFF0C;&#x800C;&#x4E0D;&#x662F;<strong>obj&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;a</strong>,&#x4E5F;&#x5C31;&#x662F;&#x8BF4;<code>b1: this.a,</code>&#x4E2D;&#x7684;this&#x6307;&#x5411;window&#x3002;&#x800C;<code>b2: () =&gt; this.a,</code>&#x4E2D;&#x7684;this&#x540C;&#x6837;&#x6307;&#x5411;window&#xFF0C;&#x8FD4;&#x56DE;&#x5168;&#x5C40;&#x53D8;&#x91CF;a&#x7684;&#x503C;&#x3002;</p>
<h4 class="mume-header" id="%E7%AC%AC%E4%BA%8C%E4%B8%AA%E7%A4%BA%E4%BE%8B">&#x7B2C;&#x4E8C;&#x4E2A;&#x793A;&#x4F8B;&#xFF1A;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// demo2</span>
<span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token function">fn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token keyword">var</span> a <span class="token operator">=</span> <span class="token number">2</span><span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 0</span>

  <span class="token keyword">const</span> <span class="token function-variable function">subf</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">subf</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 0</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</pre><h4 class="mume-header" id="%E7%AC%AC%E4%B8%89%E4%B8%AA%E7%A4%BA%E4%BE%8B">&#x7B2C;&#x4E09;&#x4E2A;&#x793A;&#x4F8B;&#xFF1A;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// demo3</span>
<span class="token keyword">var</span> obj2 <span class="token operator">=</span>  <span class="token punctuation">{</span>
  a<span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
  b1<span class="token punctuation">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">;</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
  b2<span class="token punctuation">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj2<span class="token punctuation">.</span><span class="token function">b1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 3</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj2<span class="token punctuation">.</span><span class="token function">b2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 3</span>
</pre><p>&#x8FD9;&#x4E2A;&#x793A;&#x4F8B;&#x4E2D;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x5916;&#x7684;this&#x662F;&#x54EA;&#x4E2A;&#xFF1F;&#x6211;&#x4EEC;&#x5728;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x5916;&#x9762;&#x52A0;&#x4E2A;this.a&#x770B;&#x770B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">var</span> obj2 <span class="token operator">=</span>  <span class="token punctuation">{</span>
  a<span class="token punctuation">:</span> <span class="token number">3</span><span class="token punctuation">,</span>
  b1<span class="token punctuation">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">;</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
  b2<span class="token punctuation">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">,</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj2<span class="token punctuation">.</span><span class="token function">b1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 3</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj2<span class="token punctuation">.</span><span class="token function">b2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 3</span>
</pre><h4 class="mume-header" id="%E7%AC%AC%E5%9B%9B%E4%B8%AA%E7%A4%BA%E4%BE%8B">&#x7B2C;&#x56DB;&#x4E2A;&#x793A;&#x4F8B;&#xFF1A;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// demo4</span>
<span class="token keyword">var</span> obj3 <span class="token operator">=</span>  <span class="token punctuation">{</span>
  a<span class="token punctuation">:</span> <span class="token number">4</span><span class="token punctuation">,</span>
  b1<span class="token punctuation">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">;</span><span class="token punctuation">}</span><span class="token punctuation">,</span>
  b2<span class="token punctuation">:</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj4<span class="token punctuation">.</span><span class="token function">b1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 4</span>
console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>obj4<span class="token punctuation">.</span><span class="token function">b2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 4</span>
</pre><p>&#x8FD9;&#x91CC;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x8FD4;&#x56DE;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x518D;&#x8FD4;&#x56DE;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#xFF0C;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x8FD4;&#x56DE;this.a&#x3002;&#x8FD9;&#x4E2A;this&#x662F;&#x8C01;&#xFF1F;&#x5C31;&#x662F;&#x6700;&#x540E;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x5916;&#x9762;&#x7684;&#x5916;&#x9762;&#x7684;&#x5916;&#x9762;&#x7684;&#x90A3;&#x4E2A;this,&#x4E5F;&#x5C31;&#x662F;obj3.b1&#x4E2D;&#x7684;&#x90A3;&#x4E2A;this&#xFF0C;&#x4E5F;&#x5C31;&#x662F;obj3.a&#x3002;&#x1F603;<br>
&#x5B9E;&#x60C5;&#x662F;&#x8FD9;&#x6837;&#xFF1A;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x6CA1;&#x6709;&#x81EA;&#x5DF1;&#x7684;this&#xFF0C;&#x6240;&#x4EE5;&#x4E0D;&#x7BA1;&#x5D4C;&#x5957;&#x591A;&#x5C11;&#x5C42;&#xFF0C;&#x90FD;&#x4E0D;&#x5F71;&#x54CD;this&#x662F;&#x8C01;&#x3002;</p>
<h4 class="mume-header" id="%E7%AC%AC%E4%BA%94%E4%B8%AA%E7%A4%BA%E4%BE%8B">&#x7B2C;&#x4E94;&#x4E2A;&#x793A;&#x4F8B;&#xFF1A;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// demo5</span>
<span class="token keyword">function</span> <span class="token function">f0</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">var</span> a <span class="token operator">=</span> <span class="token number">5</span><span class="token punctuation">;</span>

  <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">var</span> b1 <span class="token operator">=</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">;</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>b1<span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 0</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">var</span> <span class="token function-variable function">b2</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span> <span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">;</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token function">b2</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 0</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">200</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>

<span class="token function">f0</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 0  0</span>
</pre><p>&#x6211;&#x4EEC;&#x90FD;&#x77E5;&#x9053;setTimeout&#x4E2D;&#x7684;&#x90A3;&#x4E2A;function&#x8FD0;&#x884C;&#x4E8E;&#x5168;&#x5C40;&#x73AF;&#x5883;&#x4E0B;&#xFF0C;&#x56E0;&#x6B64;&#x91CC;&#x9762;&#x7684;this&#x6307;&#x5411;window&#x3002;&#x800C;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x6CA1;&#x6709;&#x81EA;&#x5DF1;&#x7684;this&#xFF0C;&#x6240;&#x4EE5;&#x7B2C;&#x4E8C;&#x4E2A;setTimeout&#x4E2D;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x7684;this&#x4E5F;&#x6307;&#x5411;window.</p>
<p>&#x90A3;&#x4E48;setTimeout&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#x4F7F;&#x7528;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4F1A;&#x662F;&#x4E2A;&#x4EC0;&#x4E48;&#x60C5;&#x51B5;&#xFF1F;&#x770B;&#x4E0B;&#x4E00;&#x4E2A;&#x793A;&#x4F8B;&#x3002;</p>
<h4 class="mume-header" id="%E7%AC%AC%E5%85%AD%E4%B8%AA%E7%A4%BA%E4%BE%8B">&#x7B2C;&#x516D;&#x4E2A;&#x793A;&#x4F8B;&#xFF1A;</h4>

<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// demo6</span>
<span class="token keyword">function</span> <span class="token function">f1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span> 
  <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span>  
  <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token function">f1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 0  0</span>
</pre><p>&#x8FD9;&#x91CC;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4F5C;&#x4E3A;setTimeout&#x7684;&#x7B2C;&#x4E00;&#x4E2A;&#x53C2;&#x6570;&#xFF0C;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x5916;&#x9762;&#x7684;&#x90A3;&#x4E2A;this&#x662F;&#x8C01;?&#x628A;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x6362;&#x6210;<code>this.fn()</code>&#xFF1A;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">function</span> <span class="token function">f1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 0</span>
  <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">fn</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
<span class="token punctuation">}</span>
</pre><p>&#x6211;&#x4EEC;&#x8FD9;&#x91CC;&#x4E0D;&#x7528;&#x4E86;&#x89E3;this.fn()&#x6709;&#x4EC0;&#x4E48;&#x529F;&#x80FD;&#xFF0C;&#x770B;&#x5230;&#x5B83;&#x6211;&#x4EEC;&#x5C31;&#x4F1A;&#x660E;&#x767D;&#x4E86;this.fn()&#x4E2D;&#x7684;this&#x548C;&#x524D;&#x9762;&#x4E00;&#x884C;&#x4E2D;&#x7684;this.a&#x4E2D;&#x7684;this&#x662F;&#x540C;&#x4E00;&#x4E2A;this&#x3002;</p>
<p>&#x6269;&#x5C55;&#x4E00;&#x4E0B;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// &#x8FD9;&#x6837;&#x6267;&#x884C;</span>
f1<span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span><span class="token punctuation">{</span>a<span class="token punctuation">:</span> <span class="token number">7</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// 7  7</span>
</pre><p>&#x7ED3;&#x679C;&#x662F;&#x8F93;&#x51FA;&#x4E24;&#x4E2A;7,<br>
&#x4E3A;&#x4EC0;&#x4E48;&#xFF1F;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token comment">// demo6</span>
<span class="token keyword">function</span> <span class="token function">f1</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span>   <span class="token comment">// &#x56E0;&#x4E3A;&#x901A;&#x8FC7;call&#x5BF9;this&#x7684;&#x7ED1;&#x5B9A;&#xFF0C;f1&#x4E2D;&#x7684;this&#x6307;&#x5411; {a: 7}</span>
  <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>a<span class="token punctuation">)</span><span class="token punctuation">;</span>  <span class="token comment">// &#x540C;&#x6837;&#x8FD9;&#x91CC;this&#x6307;&#x5411; {a: 7}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</pre><p>&#x540C;&#x7406;&#xFF1A;</p>
<pre data-role="codeBlock" data-info="javascript" class="language-javascript"><span class="token keyword">var</span> bindf1 <span class="token operator">=</span> f1<span class="token punctuation">.</span><span class="token function">bind</span><span class="token punctuation">(</span><span class="token punctuation">{</span>a<span class="token punctuation">:</span> <span class="token number">8</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span> 
<span class="token function">bindf1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 8 8</span>
</pre><h2 class="mume-header" id="%E6%80%BB%E7%BB%93">&#x603B;&#x7ED3;</h2>

<p>&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x6CA1;&#x6709;&#x81EA;&#x5DF1;&#x7684;this&#xFF0C;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E2D;&#x7528;this&#x548C;&#x666E;&#x901A;&#x8BED;&#x53E5;&#x4E2D;&#x7684;this&#x6CA1;&#x4EC0;&#x4E48;&#x533A;&#x522B;&#xFF0C;&#x6240;&#x4EE5;&#xFF0C;&#x4F60;&#x77E5;&#x9053;&#x975E;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E0B;&#x600E;&#x4E48;&#x7528;this,&#x5C31;&#x77E5;&#x9053;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E0B;&#x600E;&#x4E48;&#x7528;this&#x3002;<br>
&#x5173;&#x4E8E; &#x201C;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x5BF9;this&#x56FA;&#x5B9A;&#x5316;&#xFF0C;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E2D;&#x7684;this&#x7ED1;&#x5B9A;&#x5B9A;&#x4E49;&#x65F6;&#x6240;&#x5728;&#x7684;&#x4F5C;&#x7528;&#x57DF;&#xFF0C;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x4E0D;&#x80FD;&#x901A;&#x8FC7; call() &#x6216; apply() &#x65B9;&#x6CD5;&#x7ED1;&#x5B9A;this&#x201D; &#x7B49;&#x63CF;&#x8FF0;&#xFF0C;&#x90FD;&#x6E90;&#x4E8E;&#x7BAD;&#x5934;&#x51FD;&#x6570;&#x6CA1;&#x6709;&#x81EA;&#x5DF1;&#x7684;this&#x3002;</p>

      